//
//  PHProgressBar.m
//  PhnixHome
//
//  Created by Levy Xu on 2018/1/10.
//  Copyright © 2018年 Levy Xu. All rights reserved.
//

#import "PHProgressBar.h"

@interface PHProgressBar()


@end

@implementation PHProgressBar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        _titleLabel = [[QMUILabel alloc] init];
        _titleLabel.font = CodeFontMake(14);
        _titleLabel.textColor = UIColorGray4;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleLabel];
        
        
        UIColor *color = GQDThemeManager.currentTheme.themeTintColor;
        _progressBar = [[YLProgressBar alloc] init];
        _progressBar.progressTintColors = @[[color colorWithAlphaComponent:0.5], [color colorWithAlphaComponent:1.0] ];
        _progressBar.indicatorTextDisplayMode = YLProgressBarIndicatorTextDisplayModeNone;
        _progressBar.hideGloss = YES;
        _progressBar.hideStripes = YES;
        _progressBar.hideTrack = YES;
        _progressBar.indicatorTextLabel.font = CodeFontMake(10);
        _progressBar.indicatorTextLabel.textColor = UIColorGray4;
        [self addSubview:_progressBar];
        
        _valueLabel = [[QMUILabel alloc] init];
        _valueLabel.font = CodeFontMake(12);
        _valueLabel.textColor = UIColorGray4;
        _valueLabel.textAlignment = NSTextAlignmentRight;
        _valueLabel.text = @"0.0 RMB";
        [self addSubview:_valueLabel];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    _titleLabel.frame = CGRectMake(0, self.bounds.size.height / 2 - 10, 60, 20);
    _progressBar.frame = CGRectMake(60, 0, self.bounds.size.width - 120, self.bounds.size.height);
    _valueLabel.frame = CGRectMake(self.bounds.size.width - 60, _valueLabel.qmui_top, 60, _titleLabel.qmui_height);
}

-(void)setTitle:(NSString *)title {
    _title = title;
    _titleLabel.text = title;
}

@end
